/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.estante;

import br.uefs.cedoc.controle.Command;
import br.uefs.cedoc.controle.CommandException;
import br.uefs.cedoc.db.exception.DBConnectionException;
import br.uefs.cedoc.db.estante.DBEstante;
import br.uefs.cedoc.entidades.EstanteBean;
import br.uefs.cedoc.entidades.SerieBean;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Gregory Porto
 */

public class GetAllEstanteCommand implements Command {
  private String next;

    public GetAllEstanteCommand(String next) {
          this.next = next;
    }



    public String execute(HttpServletRequest req)
    throws CommandException {

        try {
            HttpSession session = req.getSession(true);
            DBEstante dbestante = new DBEstante();
            SerieBean serie = (SerieBean)session.getAttribute("serie");
           
            EstanteBean[] estantes = dbestante.listarEstantes( serie.getIdSerie());
            req.setAttribute("estante",estantes);

            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }  
            return next;
     
        } 
    }

